package cn.tedu.review;

import java.util.Scanner;

/**简易计算器*/
public class TestCalc {
    public static void main(String[] args) {
        fo();
    }

    private static void fo() {
        while(true){
            System.out.println("请您输入第一个数");
            int a =new Scanner(System.in).nextInt();
            System.out.println("请您输入第二个数");
            int b =new Scanner(System.in).nextInt();
            System.out.println("请您输入要计算的运算符,支持+-*/");
            String s=new Scanner(System.in).nextLine();
            switch (s){
                case "+":f1(a,b);break;
                case "-":f2(a,b);break;
                case "*":f3(a,b);break;
                case "/":f4(a,b);break;
                default:
                    System.out.println("您输入的运算符号不正确");
            }
            System.out.println("如果想退出请输入1,继续请输入2");
            int flag=new Scanner(System.in).nextInt();
            if (flag==1){
                break;
            }
        }
    }

    private static void f4(int a, int b) {
        System.out.println(a+"/"+b+"="+(a/b));
    }

    private static void f3(int a, int b) {
        System.out.println(a+"*"+b+"="+(a*b));
    }

    private static void f2(int a, int b) {
        System.out.println(a+"-"+b+"="+(a-b));
    }

    private static void f1(int a, int b) {
        System.out.println(a+"+"+b+"="+(a+b));
    }

}
